package com.zjsru.controller;

import com.zjsru.pojo.Order;
import com.zjsru.pojo.User;
import com.zjsru.service.OrderService;
import com.zjsru.feign.UserClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderController {
    @Autowired
    OrderService orderService;

    @Autowired
    UserClient userClient;

    @GetMapping("/order/query/{id}")
    public Order queryOrderById(@PathVariable("id") Long id) {
        Order order = orderService.queryOrderById(id);
        User user = userClient.getUserById(order.getUser_Id());
        order.setUser(user);
        return order;
    }
}